FROM mindcollapse/malware-multi-scan-scanner:latest

ARG DRWEB_KEY
ENV DRWEB_KEY=$DRWEB_KEY

ARG DRWEB_URL=https://download.geo.drweb.com/pub/drweb/unix/workstation/11.1/drweb-11.1.1-av-linux-amd64.run
ENV DRWEB_URL=$DRWEB_URL

RUN apt-get update && apt-get install build-essential ca-certificates wget -y

RUN wget -q $DRWEB_URL -O /tmp/drweb.run && \
    chmod +x /tmp/drweb.run && \
    DRWEB_NON_INTERACTIVE=yes /tmp/drweb.run && \
    rm -f /tmp/drweb.run

RUN /opt/drweb.com/bin/drweb-configd -d -p /var/run/drweb-configd.pid && \
    if [ -z "$DRWEB_KEY" ]; then drweb-ctl license --GetDemo; \
    else drweb-ctl license --GetRegistered "$DRWEB_KEY"; \
    fi && kill $(cat /var/run/drweb-configd.pid) 
    
RUN /opt/drweb.com/bin/drweb-configd -d -p /var/run/drweb-configd.pid && \
    (drweb-ctl update --Stop || exit 0) && \
    drweb-ctl update && \
    kill $(cat /var/run/drweb-configd.pid)
    
ENV BackendType=DrWeb
    
ENTRYPOINT /opt/drweb.com/bin/drweb-configd -d -p /var/run/drweb-configd.pid && /worker/MalwareMultiScan.Scanner